package com.git.xiaoyou11.service;

import java.util.List;

import org.springframework.data.redis.connection.SortParameters.Range;

public interface BaseClientRedisRepositoryDao<T> {
	
	/**
	 * 根据时间范围查询
	 * @param range
	 * @return
	 */
	public List<T> findEntityListByRange(Range range);
	
	
	/*	*//**
	 * 根据范围查询最新条目
	 * @return
	 *//*
	public List<T> findEntityListByRange(Range range){
		String nid = "nid:*->"; 
		final String title = "title";
		final String content = "content";
		final String date = "date";
		final String externalLink = "externalLink";
		final String externalLoginName = "externalLoginName";
		final String externalLoginPwd = "externalLoginPwd";
		SortQuery<String> query = SortQueryBuilder.
				sort(KeyGenUtils.timeline()).
				by(nid+content).
				alphabetical(true).
				order(Order.DESC).
				get(nid+title).
				get(nid+content).
				get(nid+date).
				get(nid+externalLink).
				get(nid+externalLoginName).
				get(nid+externalLoginPwd).
				limit(range).build();
		BulkMapper<T, String> bm = new BulkMapper<T, String>() {

			@Override
			public T mapBulk(List<String> bulk) {
				Map<String,String> map = new LinkedHashMap<String,String>();
				Iterator<String> it = bulk.iterator();
				
				String title = it.next();
				String content = it.next();
				String date = it.next();
				String externalLink = it.next();
				String externalLoginName = it.next();
				String externalLoginPwd = it.next();
				
				map.put("title", title);
				map.put("content", content);
				map.put("date", date);
				map.put("externalLink", externalLink);
				map.put("externalLoginName", externalLoginName);
				map.put("externalLoginPwd", externalLoginPwd);
				
				return postMapper.fromHash(map);
			}
			
		};
		
		return template.sort(query, bm);
	}*/
}
